package engine

import (
	"dbManager/manager/engine"
	"dbManager/manager/strategy/deleteStrategy"
	"github.com/zhuxiujia/GoMybatis"
)

var DB Engine

func init() {
	DB.new()
}

type Engine struct {
	DbManager engine.Manager
	Session   GoMybatis.Session
}

func (e *Engine) new() {
	//初始化DbManager
	e.DbManager = engine.NewDbManager()
	//设置解析策略
	e.DbManager.SetParseConfigFileStrategy()
	//解析数据库配置文件
	e.DbManager.SetConfig(e.DbManager.GetParseConfigFileStrategy().Parse())
	//连接数据库
	e.DbManager.OpenSql()
	//设置
	e.DbManager.SetDeleteStrategy(deleteStrategy.UpdateTimePrioity{
		MaxExpirTime: e.DbManager.GetSqlConfig().GetMaxExpirTime(),
	})
}
